﻿
Imports osi.root.constants
Imports osi.root.connector

Namespace error_handle
    Public Class error_type_selected_error_writer
        Implements ierror_writer

        Public skip_error_type As String = Nothing
        Public ReadOnly writer As ierror_writer

        Public Sub New(ByVal writer As ierror_writer)
            assert(Not writer Is Nothing)
            Me.writer = writer
        End Sub

        Public Function [select](ByVal error_type As error_type,
                                 ByVal error_type_char As Char) As Boolean Implements ierror_writer.select
            Return ((error_type <> error_type.other AndAlso
                     strindexof(skip_error_type, _error_handle.error_type_char(error_type).ToString) = npos) OrElse
                    (error_type = error_type.other AndAlso
                     strindexof(skip_error_type, error_type_char) = npos)) AndAlso
                   writer.select(error_type, error_type_char)
        End Function

        Public Sub write(ByVal error_type As error_type, ByVal s As String) Implements ierror_writer.write
            writer.write(error_type, s)
        End Sub
    End Class
End Namespace
